package com.da.javatest.niuke.jianzhi;

import java.util.ArrayList;
import java.util.Collections;

import com.da.javatest.niuke.common.ListNode;

/**
 * @author chenlida
 * @date 2020/10/20 16:17
 * https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C3Solution {
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        ArrayList<Integer> list = new ArrayList<>();
        while (listNode != null) {
            list.add(listNode.val);
            listNode = listNode.next;
        }
        Collections.reverse(list);
        return list;
    }
}
